<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<meta name="viewport" content="width=device-width, initial-scale=1.0">
	<title>Document</title>
</head>
<body>
	<script type="text/javascript">
		/*async function async1(){
			console.log('async1 start')
			await async2()
			console.log('async1 end')
		}
		async function async2() {
			console.log('async2')
		}
		console.log('script start')
		setTimeout(() => {
			console.log('setTimeout')
		},0)
		async1()
		new Promise((resolve) => {
			console.log('promise1')
			resolve()
		}).then(() => {
			console.log('promise2')
		})
		console.log('script end')*/
		/*
			注意：
			这里的await async2() 相当于 new Promise(() => {
				async2()
			}).then(() => {
				console.log('async1 end')
			})
			await 后边的语句，是一个异步的任务，将添加到微任务队列中
			await 函数后的所有代码，将添加到微任务队列中
		*/
		/*
			script start
			async1 start
			async2
			promise1
			script end
			async1 end
			promise2
			setTimeout
		*/

		function* fn(){
			console.log('one');
			yield '1';
			console.log('two');
			yield '2';
			console.log('three');
			return '3'
		}

		function* sum(a) {
		  console.log('a:', a);
		  let b = yield 1;
		  console.log('b:', b);
		  let c = yield 2;
		  console.log('c:', c);
		  let sum = a + b + c;
		  console.log('sum:', sum)
		  return sum;
		}
	</script>
</body>
</html>